//scale发生变化的呼吸效果

cc.Class({
    extends: cc.Component,

    properties: {

    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        this.time = 0
        this.breathing = false

    },
    takeBreath(period,width,height){
        try{
            this.originalWidth = this.node.getComponent(cc.Sprite)._spriteFrame._originalSize.width
            this.originalHeight = this.node.getComponent(cc.Sprite)._spriteFrame._originalSize.height
        }catch(err){
            
        }
        
        if(period){
            this.period = period
        }else{
            this.period = 3
        }

        if(width){
            this.width = width
        }else{
            this.width = 0.02
        }

        if(height){
            this.height = height
        }else{
            this.height = 0.02
        }

        this.breathing = true

    },
    stop(){
        this.breathing =false
    },
    update (dt) {
        if(this.breathing){
            this.time += dt
            this.node.width = this.originalWidth *(1 + this.width * Math.sin(this.time *2*3.1415926/ this.period))
            this.node.height = this.originalHeight*(1 - this.height * Math.sin(this.time *2*3.1415926/ this.period))
        }

    },
});
